
copts_rel = [
  "-fPIC",
  # Lto breaks linking on clang-11? Or a bazel bug?
  # "-flto=full"
  "-fno-exceptions",
  "-fno-rtti",
  "-fstrict-aliasing",
  "-fstrict-enums",
  "-fstrict-float-cast-overflow",
  "-fstrict-overflow",
  "-fstrict-return",
  # We want to eagerly adopt optimizations when new compilers roll around
  "-Wno-ignored-optimization-argument",
  "-Wall",
  "-Wextra",
  # We can't error-on-warning because bazel does this:
  #   ld: warning: ignoring duplicate libraries: '-lc++'
  # "-Werror",
  "-Wpedantic",
  "-std=c++20",
  "-Iinclude",
  # Release flags
  "-DNDEBUG",
  "-march=native",
  "-mtune=native",
  "-fexpensive-optimizations",
  "-fwhole-program",
  "-fomit-frame-pointer",
  "-O3",
]

linkopts = select({
  "@platforms//os:macos": [
    "-framework", "CoreServices",
    "-framework", "CoreFoundation",
  ]
})

cc_library(
  name = "watcher-hdr",
  hdrs = ["include/wtr/watcher.hpp"],
  includes = ["include"],
  visibility = ["//visibility:public"],
  linkopts = linkopts,
)

cc_binary(
  name = "ww",
  srcs = ["src/wtr/watcher/main.cpp"],
  deps = ["//:watcher-hdr"],
  copts = copts_rel,
  linkopts = linkopts,
)

cc_binary(
  name = "ww-tiny",
  srcs = ["src/wtr/tiny_watcher/main.cpp"],
  deps = ["//:watcher-hdr"],
  copts = copts_rel,
  linkopts = linkopts,
)

